class Song {
  constructor({id, mid, singer, name, album, duration, image, url}) {
    this.id = id
    this.mid = mid // 歌手id
    this.singer = singer
    this.name = name
    this.album = album // 专辑id
    this.duration = duration
    this.image = image
    this.url = url
  }
}

export function createSong(musicData) {
  return new Song({
    id:musicData.songid,
    mid:musicData.songmid,
    singer:filterSinger(musicData.singer),
    name:musicData.songname,
    album:musicData.albumname,
    duration:musicData.interval,
    image:`https://y.gtimg.cn/music/photo_new/T002R300x300M000${musicData.albummid}.jpg?max_age=2592000`,
    url:`http://dl.stream.qqmusic.qq.com/http://dl.stream.qqmusic.qq.com/C400${musicData.songmid}.m4a?guid=7516348006&vkey=0231DD154F6D77F42B253F9815C624F6CD83283FC0D0978A78D7C30B47A2F70925106ED701BEF4A051D6A4DBCF4CEBFF4C12AB883AD70F11&uin=0&fromtag=38`
  })
}

const filterSinger = (singer) => {
  let ret = []
  if (!singer) {
    return ''
  }
  singer.forEach(s => {
    ret.push(s.name)
  })

  return ret.join('/')
}
